package guda.house.dal.dao.impl;

import guda.grape.autogen.common.BaseDAO;
import guda.house.dal.dao.AdminRoleRelDAO;
import guda.house.dal.dataobject.AdminRoleRelDO;
import guda.grape.autogen.common.page.BaseQuery;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class AdminRoleRelDAOImpl extends BaseDAO implements AdminRoleRelDAO {

    @Override
	public Long insert(AdminRoleRelDO adminRoleRel) {
	      try {
                return (Long) getSqlMapperW().insert("admin_role_rel.insert",adminRoleRel);
          } catch (Exception e) {
                throw new RuntimeException(e);
          }

	}

    @Override
	public AdminRoleRelDO getAdminRoleRelById(Long relId) {
	    return (AdminRoleRelDO)getSqlMapClientTemplate().queryForObject("admin_role_rel.getAdminRoleRelById", relId);
	}

    @Override
	public boolean delAdminRoleRelById(Long relId) {
	    int num = 0;
        try {
            num = getSqlMapperW().delete("admin_role_rel.delAdminRoleRelById",relId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        if(num>0){
            return true;
        }else{
            return false;
        }
	}

    @Override
	public List<AdminRoleRelDO> getAdminRoleRelByIds(List idsList) {
        Map m = new HashMap();
        m.put("idsList",idsList);
		return getSqlMapClientTemplate().queryForList("admin_role_rel.selectByIds", m);
	}

    @Override
	public void cleanAutoIncrement(Long relId) {
	    try {
            getSqlMapperW().update("admin_role_rel.cleanAutoIncrement",relId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
	}

    @Override
    public List<AdminRoleRelDO> selectForPage(BaseQuery baseQuery) {
        return getSqlMapClientTemplate().queryForList("admin_role_rel.selectForPage", baseQuery);
    }

    @Override
    public int countForPage(BaseQuery baseQuery) {
        return (Integer)getSqlMapClientTemplate().queryForObject("admin_role_rel.countForPage",baseQuery);
    }

    @Override
    public void updateByIdSelective(AdminRoleRelDO adminRoleRel) {
        try {
            getSqlMapperW().update("admin_role_rel.updateByIdSelective",adminRoleRel);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void delByAdminId(Long adminId) {

        try {
            getSqlMapperW().delete("admin_role_rel.delByAdminId",adminId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }

    @Override
    public List<AdminRoleRelDO> selectByAdminId(Long adminId) {
        return getSqlMapClientTemplate().queryForList("admin_role_rel.selectByAdminId", adminId);
    }

}

